import { IPSDEMSLogic } from './ipsdemslogic';
import { IPSDEMSLogicLink } from './ipsdemslogic-link';
import { IPSDEMSLogicLinkGroupCond } from './ipsdemslogic-link-group-cond';
import { IPSDEMSLogicNode } from './ipsdemslogic-node';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEMSLogicLinkImpl extends PSModelObjectImpl implements IPSDEMSLogicLink {
  get codeName(): string {
    return this.M.codeName;
  }

  protected dstpsdemslogicnode: IPSDEMSLogicNode | null = null;

  getDstPSDEMSLogicNode(): IPSDEMSLogicNode | null {
    if (this.dstpsdemslogicnode != null) return this.dstpsdemslogicnode;
    const value = this.M.getDstPSDEMSLogicNode;
    if (value == null) {
      return null;
    }
    const ipsdemslogic = this.getParentPSModelObject('dataentity.logic.IPSDEMSLogic') as IPSDEMSLogic;
    if (ipsdemslogic != null) {
      this.dstpsdemslogicnode = ipsdemslogic.findPSDEMSLogicNode(value);
    }
    return this.dstpsdemslogicnode;
  }

  get dstPSDEMSLogicNode(): IPSDEMSLogicNode | null {
    return this.getDstPSDEMSLogicNode();
  }

  getDstPSDEMSLogicNodeMust(): IPSDEMSLogicNode {
    const value = this.getDstPSDEMSLogicNode();
    if (value == null) {
      throw new Error('未指定目标主状态节点对象');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdemslogiclinkgroupcond: IPSDEMSLogicLinkGroupCond | null = null;

  getPSDEMSLogicLinkGroupCond(): IPSDEMSLogicLinkGroupCond | null {
    if (this.psdemslogiclinkgroupcond != null) return this.psdemslogiclinkgroupcond;
    const value = this.M.getPSDEMSLogicLinkGroupCond;
    if (value == null) {
      return null;
    }
    this.psdemslogiclinkgroupcond = this.getPSModel4('dataentity.logic.IPSDEMSLogicLinkGroupCond', value, 'getPSDEMSLogicLinkGroupCond') as IPSDEMSLogicLinkGroupCond;
    return this.psdemslogiclinkgroupcond;
  }

  get psDEMSLogicLinkGroupCond(): IPSDEMSLogicLinkGroupCond | null {
    return this.getPSDEMSLogicLinkGroupCond();
  }

  getPSDEMSLogicLinkGroupCondMust(): IPSDEMSLogicLinkGroupCond {
    const value = this.getPSDEMSLogicLinkGroupCond();
    if (value == null) {
      throw new Error('未指定连接条件对象');
    }
    return value;
  }

  protected srcpsdemslogicnode: IPSDEMSLogicNode | null = null;

  getSrcPSDEMSLogicNode(): IPSDEMSLogicNode | null {
    if (this.srcpsdemslogicnode != null) return this.srcpsdemslogicnode;
    const value = this.M.getSrcPSDEMSLogicNode;
    if (value == null) {
      return null;
    }
    const ipsdemslogic = this.getParentPSModelObject('dataentity.logic.IPSDEMSLogic') as IPSDEMSLogic;
    if (ipsdemslogic != null) {
      this.srcpsdemslogicnode = ipsdemslogic.findPSDEMSLogicNode(value);
    }
    return this.srcpsdemslogicnode;
  }

  get srcPSDEMSLogicNode(): IPSDEMSLogicNode | null {
    return this.getSrcPSDEMSLogicNode();
  }

  getSrcPSDEMSLogicNodeMust(): IPSDEMSLogicNode {
    const value = this.getSrcPSDEMSLogicNode();
    if (value == null) {
      throw new Error('未指定源主状态节点对象');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get defaultLink(): boolean {
    return this.M.defaultLink != null ? this.M.defaultLink : false;
  }

  get cls(): string {
    return 'PSDEMSLogicLinkImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDEMSLogicLink') return true;
    return super.instanceof(cls);
  }
}
